1. Field of the Invention
The present invention relates to a rate control method and apparatus for encoding moving pictures, and more particularly, to a rate control apparatus and method for maintaining a constant bit rate and constant picture quality at the same time, and a computer readable recording medium having embodied thereon a computer program for the method. The present application is based on Korean Patent Application No. 2002-44501, which is incorporated herein by reference.
2. Description of the Related Art
In general, when moving pictures are encoded, the amount of bits generated in an encoder varies according to the characteristics of scenes. In order for the encoder to transmit moving picture information in real time through a transmission channel having a constant transmission speed, it is necessary to adjust image information, which is encoded and transmitted, to a predetermined bit rate. To do this, first, encoded image information is stored in a buffer having a predetermined size and then transmitted to a decoder at a predetermined transmission speed. At this time, the method for controlling the encoder in order to prevent an underflow or overflow is referred to as a bit rate control method.
Rate control methods can be divided into two methods: a frame-based rate control method in which image data that are input at a predetermined time interval are controlled in units of frames, and a method in which an input image is divided into blocks, each having a predetermined size, that is, a macro block, and the image is controlled in units of macro blocks.
FIG. 1 is a block diagram of a rate control apparatus according to the prior art method for controlling a bit rate in units of frame.
An initial value calculating unit 110 receives a requested bit rate and the frame rate of the input frames that are desired to be encoded. Then, the initial value calculating unit 110 calculates an initial value needed in controlling a bit rate and transmits the result to a target encoding bit number calculating unit 120. In general, initial value calculation is performed only once in the beginning stage of encoding.
The target encoding bit number calculating unit 120 calculates the number of bits that can be assigned to each frame, by using the initial values calculated in the initial value calculating unit 110. Considering the calculated number of bits that can be assigned to each frame and the state of a buffer 140 so as to prevent an overflow or an underflow, the target encoding bit number calculating unit 120 calculates the number of target encoding bits of the frame that is currently being encoded. At this time, the number of bits that can be assigned to each frame is obtained by subtracting the number of bits that are already encoded and used from the number of the total number of bits for satisfying a requested bit rate, and then dividing the number of remaining bits by the number of remaining frames. Also, the state of the buffer 140 may be input directly from the buffer 140 or may be obtained by calculation using the bit rate, the number of encoding bits of the previous frame, and the buffer state in the previous frame.
A rate control and encoding unit 130 controls the encoding process so that a bit stream which is encoded to approximate to the target encoding bit number provided by the target encoding bit number calculating unit 120 is output. This will be explained later referring to FIG. 2.
The buffer 140 receives and stores the encoded bit stream, and then transmits the bit stream to a decoder (not shown) through a transmission line.
After the encoding process for one frame is finished, a next frame skip control unit 150 receives information on the current occupied state of the buffer from the buffer 140. If it is determined that the filled state of the bit stream in the buffer 140 exceeds a predetermined limit, the next frame skip control unit 150 generates a frame skip control signal so that the next frame is not encoded in order to prevent loss of image information due to an overflow in the buffer 140, and outputs the generated frame skip control signal to a control unit 160.
The control unit 160 controls the entire encoding process, and in particular receives the frame skip control signal for controlling the bit rate and determines whether or not to encode the next input frame.
FIG. 2 is a block diagram of the rate control and encoding unit 130 of the prior art rate control apparatus of FIG. 1.
A quantization parameter calculation unit 210 receives a target encoding bit number from the target encoding bit number calculating unit 120, and model parameters for calculating a quantization parameter from a model parameter update unit 230, and calculates a quantization parameter. The calculated quantization parameter is used in an encoding unit 220 and the model parameter update unit 230.
The encoding unit 220 receives the quantization parameter calculated in the quantization parameter calculating unit 210, performs actual encoding, and sends an encoded bit stream to the buffer 140. Also, the encoding unit 220 sends the size of the encoded bit stream to the model parameter update unit 230.
The model parameter update unit 230 updates the model parameter by using the quantization parameter information calculated in the quantization parameter calculating unit 210 and the size information of the bit stream encoded in the encoding unit 220. That is, the model parameter update unit 230 updates the model parameter by using the already used quantization parameter value and the size of the bit stream encoded according to the parameter value. At this time, the information used here includes quantization parameter information and size information of the encoded bit stream that are used for frames in the range of a sliding window, after applying the sliding window to the frames close to the currently encoded frame on the time axis. Thus, the model parameter update unit 230 employs the sliding window method and reflects information on a predetermined number of encoded frames to the current frame to update the model.
Thus, in the prior art, in order to efficiently adjust a transmission rate on a transmission line, encoding of the next frame is skipped according to the state of the buffer. However, only the buffer state of the encoder is considered in the prior art without considering the characteristics of input image data. Accordingly, if a model applied to the previous frame does not work appropriately in the current frame because of changes in the characteristics of input image data, the quality of the encoded frame is degraded. Also, if an excessive number of bits are used according to a wrongfully selected quantization parameter value, the number of bits assigned to the next frames decreases to cause a degraded picture quality.